package com.wwwc.util.web;
import java.util.*;

public class MyStringCheck {

    public static boolean isNumber(String number)
    {
	String format = "1234567890";
	if(number.indexOf(" ") != -1) {
	    return false;
	}

	String temp = null;
	for (int i=0; i< number.length(); i++) {
	    temp = number.charAt(i)+"";
	    if(format.indexOf(temp) == -1) {
		return false; 
	    }
	} 
	return true;
    }

    public static boolean inGroup(String gstr, String str, String dim, int eqcase)
    {
	//eqcase = 0 : case sesitive
	//eqcase = 1 : case not sensitive

	if(gstr == null || gstr.length()<1 || str == null || str.length()<1) {
	    return false;
	}

	if(gstr.indexOf(dim) == -1) {
	    if(eqcase==0) {
		return(str.equals(gstr));
	    }
	    if(eqcase==1) {
		return(str.equalsIgnoreCase(gstr));
	    }
	}
	else {
	    StringTokenizer stk = new StringTokenizer(gstr, dim);
	    while(stk.hasMoreTokens()) {
		if(eqcase==0) {
		    if(str.equals(stk.nextToken())) {
			return true;
		    }
		}
		if(eqcase==1) {
		    if(str.equalsIgnoreCase(stk.nextToken())) {
			return true;
		    }
		}
	    }
	}
	return false;
    }
}


